package cc.comac.saic.hkhy.jsrj.gj.inttools.controller;

import java.util.List;
import java.util.stream.Collectors;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import cc.comac.saic.hkhy.jsrj.gj.inttools.core.R;
import cc.comac.saic.hkhy.jsrj.gj.inttools.pojo.vo.FileTypeStatVo;
import cc.comac.saic.hkhy.jsrj.gj.inttools.service.FileInfoService;

/**
 * 文件信息(FileInfo)表控制层
 *
 * @author makejava
 * @since 2025-07-02 18:26:30
 */
@RestController
@RequestMapping("file")
public class FileInfoController {
    @Autowired
    private FileInfoService fileInfoService;

    /**
     * 获取项目文件列表
     */
    @GetMapping("project-file/{projKey}/{fileType}")
    public R<?> getProjectFile(@PathVariable String projKey, @PathVariable String fileType) {
        return R.ok(fileInfoService.queryProjectFile(projKey, fileType));
    }

    /**
     * 8.1.3	开发数据版本查询接口
     */
    @GetMapping("data-version")
    public R<?> getDataVersion(@RequestParam List<String> dataKeys) {
        return R.ok(dataKeys.stream().map(s -> fileInfoService.queryVersionByDataKey(s)).collect(Collectors.toList()));
    }

    /**
     * 获取项目文件类型统计信息
     */
    @GetMapping("project-file-stats")
    public R<List<FileTypeStatVo>> getProjectFileStats(@RequestParam("projectId") Long projectId) {
        return R.ok(fileInfoService.getFileTypeStatsByProjectId(projectId));
    }

}

